package org.testfire.translator.watij.assertions;

import org.testfire.model.assertions.AssertNull;
import org.testfire.model.TestsetType;
import org.testfire.translator.TestFireTranslator;
import org.testfire.translator.TranslatorFactory;

/**
 * Created by IntelliJ IDEA.
 * User: granum
 * Date: Sep 2, 2007
 * Time: 5:49:04 PM
 *
 */
public class AssertNullTranslator<T> implements TestFireTranslator<AssertNull>
{

    public Object translate( TestsetType testset, AssertNull type )
    {
        StringBuilder buf = new StringBuilder();
        String assertName = type.isAsNotNull() ? "assertNotNull" : "assertNull";
        buf.append( String.format( "%3$s( \"%1$s\", %2$s )", type.getMessage(),
            TranslatorFactory.translate(testset,  type.getFinder() ), assertName ) );
        return buf.toString();
    }
}